package cn.chencaiju.algorithm;

import org.junit.Test;

public class MatrixTranspose {
	public int[][] transpose(int[][] A) {
		int[][] result=new int[A[0].length][A.length];
		for(int j=0;j<A[0].length;j++) {
			for(int i=0;i<A.length;i++) {
				result[j][i]=A[i][j];
			}
		}
		return result;
	}
	@Test public void test() {
		int[][] A= {{1,2,3},{4,5,6},{2,5,8}};
		int[][]	b=transpose(A);
		for(int i=0;i<b.length;i++) {
			for(int j=0;j<b[i].length;j++) {
				System.out.print(b[i][j]+" ");
			}
			System.out.println();
		}
	}
}
